Considering/Ignoring
Considering and Ignoring statements cause AppleScript to consider or ignore specific characteristics, called attributes, as it executes groups of statements.SYNTAX
considering attribute [, attribute ... and attribute ] ÿ [ but ignoring attribute [, attribute ... and attribute ] ] [ statement ]... end considering ignoring attribute [, attribute ... and attribute ] ÿ [ but considering attribute [, attribute ... and attribute ] ] [ statement ]... end ignoringwherestatement is any AppleScript statement.
attribute is an attribute to be considered or ignored. Attributes are listed next under "Attributes".
ATTRIBUTES
An attribute is a characteristic that can be considered or ignored in a Considering or Ignoring statement. A Considering or Ignoring statement
can include any of the following attributes:
case
: In string comparisons, uppercase letters are not distinguished from lowercase letters (all letters are treated as lowercase letters). If this attribute is considered, uppercase letters are distinguished from lowercase letters.
white space
: Spaces, tab characters, and return characters are considered in string comparisons. If this attribute is ignored, the strings are compared as
if these characters were not present; for example"Brick house"
would be considered equal to"Brickhouse"
.
diacriticals
: Diacritical marks (such as ´, `, ^, ¨, and ~) are considered in string comparisons. If this attribute is ignored,"résumé"
is considered equal to"resume"
, and so on.
hyphens
: In string comparisons, hyphenated words are considered different from their nonhyphenated counterparts. If this attribute is ignored, the strings are compared as if any hyphens were not present; for example"anti-war"
would be considered equal to"antiwar"
.
expansion
: In string comparisons, AppleScript normally treats the characters æ, -->, œ, and Œ as identical to the character pairs ae, AE, oe,
and OE, respectively. If this attribute is ignored, AppleScript treats these characters like single characters; for example æ would be considered not
equal to the character pair ae.
punctuation
: The punctuation marks (. , ? : ; ! \ ' " `) are considered in string comparisons. If this attribute is ignored, the strings are compared as if these punctuation marks were not present; for example"This!"
would be considered equal to"This"
.
application responses
: Normally, AppleScript waits for a response from each application command before proceeding to the next statement or operation. The response indicates if the command completed successfully,
and also returns results and error messages, if there are any. If this attribute is ignored, AppleScript does not wait for responses from application commands before proceeding to the next statement, and ignores any results or error messages that are returned. Results and error messages from AppleScript commands, scripting additions, and expressions are not affected by theapplication responses
attribute.EXAMPLES
considering case "a" comes before "b"end considering considering case and white space but ignoring diacriticals "a" comes after "b"end considering ignoring punctuation if "this !,:book" = "this book" then (* additional statements *) end if end ignoringNOTES
Thecase
,white space
,diacriticals
,hyphens
,expansion
, andpunctuation
considerations apply only to comparisons performed by AppleScript. Comparisons are performed by AppleScript if the first operand
in the comparison is a value in a script; if the first operand is a reference
to an application or system object, the comparison is performed by the application or operating system.In contrast, the
application responses
consideration applies only to application commands. AppleScript commands, scripting additions, and AppleScript expressions are not affected.As with all other control statements, you can nest Considering and Ignoring statements. If the same attribute appears in both an outer and inner statement, the attribute specified in the inner statement takes precedence. For example, in the following statement, the first comparison is
true
, because case attribute is ignored (as specified in the Ignoring statement), while the second comparison isfalse
, because the case attribute is once again considered (as specified in the inner Considering statement).
ignoring case and punctuation if "This" = "this" then beep 1 --true considering case if "This" = "this" then beep 2 --false end considering end consideringWhen attributes in an inner Considering or Ignoring statement are different from those in outer statements, they are added to the attributes to be considered and ignored. For example, in the following statement, the
first comparison isfalse
, because only case is ignored, while the second comparison istrue
, because both case and white space are ignored.
ignoring case if "This or that" = "thisorthat" then beep 2 --false ignoring white space if "This or that" = "thisorthat" then beep 1 --true end ignoring end ignoring